package cn.iocoder.yudao.module.picturebook.dal.mysql.audiorecord;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.picturebook.dal.dataobject.audiorecord.AudioRecordDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.picturebook.controller.admin.audiorecord.vo.*;
import org.apache.ibatis.annotations.Param;

/**
 * 绘本全音频 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface AudioRecordMapper extends BaseMapperX<AudioRecordDO> {

    default PageResult<AudioRecordDO> selectPage(AudioRecordPageReqVO reqVO, Long userId) {
        return selectPage(reqVO, new LambdaQueryWrapperX<AudioRecordDO>()
                .eqIfPresent(AudioRecordDO::getBookId, reqVO.getBookId())
                .eqIfPresent(AudioRecordDO::getCreator,userId)
                .eqIfPresent(AudioRecordDO::getAudioIdUrl, reqVO.getAudioIdUrl())
                .betweenIfPresent(AudioRecordDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(AudioRecordDO::getUpdateTime));
    }

    void deleteByBookId(Integer bookId);



    AudioRecordDO selectByAudioId(Integer audioId);

    void insertByUserId(@Param("audioId") Integer audioId,@Param("bookId") Long bookId,@Param("audioIdUrl") String audioIdUrl,@Param("userId") Long userId);
}